export class LogService {
    static LOG_LEVELS = {
        DEBUG: 'debug',
        INFO: 'info',
        WARN: 'warn',
        ERROR: 'error'
    };

    constructor(prefix = '') {
        this.isDebugMode = process.env.NODE_ENV === 'development';
        this.prefix = prefix ? `[${prefix}]` : '';
    }

    debug(message, ...args) {
        if (this.isDebugMode) {
            console.debug(`[AI助手]${this.prefix}[DEBUG] ${message}`, ...args);
        }
    }

    info(message, ...args) {
        console.info(`[AI助手]${this.prefix}[INFO] ${message}`, ...args);
    }

    log(message, ...args) {
        console.info(`[AI助手]${this.prefix}[log] ${message}`, ...args);
    }

    warn(message, ...args) {
        console.warn(`[AI助手]${this.prefix}[WARN] ${message}`, ...args);
    }

    error(error, context = '') {
        console.error(
            `[AI助手]${this.prefix}[ERROR] ${context}:`, 
            error instanceof Error ? error.message : error
        );

        // 可以在这里添加错误上报逻辑
        this.reportError(error, context);
    }

    async reportError(error, context) {
        if (!this.isDebugMode) {
            try {
                // 这里可以添加错误上报到服务器的逻辑
                // await fetch('your-error-reporting-endpoint', {...})
            } catch (e) {
                console.error('Error reporting failed:', e);
            }
        }
    }
} 